Skip to content

Host core: one format for revision labels, written and read in one place - #117

Merged
agorischek merged 4 commits into
mainfrom
revision-labels
Nov 21, 2026
Merged

agorischek merged 4 commits into
mainfrom
revision-labels

Conversation

@agorischek

Copy link
Copy Markdown
Collaborator

Stacked on #116. This is item G8 of the headless-host plan ("structured revision labels"), in its smaller form: one documented format with one writer and one reader.

Why

A pair's labels (ExtractionChoice.label, the view's beforeLabel and afterLabel) carry a revision's name, its commit subject and its age in one string, main · "Add auth" · 2 days ago. The Inspector wrote that string (app/revisions.ts). Four places read it back by splitting on ' · ', each its own way:

Reader Rule
ui/pickers.tsx shortLabel first part, untrimmed
vscode-ui/src/pickers.tsx shortRevisionLabel first part, trimmed, else the label
stage/chip-text.tsx chipParts name, detail, and an age guessed from the last part
stage/labels.tsx RevisionText first part, then the rest

A custom UI had to rediscover the format from the Inspector's source to draw the same chips.

What changed

packages/host/core/src/revision-label.ts, exported from the root:

  • RevisionLabelParts {name, detail?, when?};
  • formatRevisionLabel(parts);
  • parseRevisionLabel(label) → {name, detail?, subject?, when?}. Any text is all name; subject is the detail unquoted.
  • revisionLabelName(label);
  • revisionAge(date, now?), which is the Inspector's age, moved.

Every reader and the Inspector's writer use them. shortRevisionLabel (VS Code UI) and the Inspector's age remain as aliases. Labels render the same as before.

Not here

A structured ExtractionChoice (name, subject and date fields in place of the string) would touch the pair's subjectLabels and every view's label props. It can follow once this one parser is the only place that reads the string.

Docs and tests

  • docs/guides/host-core.md describes the format and the helpers. ExtractionChoice.label's doc points to them.
  • packages/host/core/test/revision-label.test.mjs covers the format round trip, a subject containing the separator, named refs, plain text and revisionAge. It has 2 tests.

Run locally:

  • tools check --fast: pass.
  • tsc for core and the VS Code UI: pass.
  • The Inspector: no errors in the touched file. The rest of its build depends on renderers that aren't built here.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues remain for the centralized revision-label helpers and their UI integrations.

No open issues 🎉

What changed in this PR

Centralizes revision-label formatting and parsing in host core, giving built-in and custom UIs a shared way to display revision names, commit details, and ages.

Changes:

  • Adds and exports shared formatting, parsing, short-name, and age helpers.
  • Migrates the Inspector’s writer and UI readers to those helpers, retaining existing aliases.
  • Documents the label format and adds tests for parsing, formatting, and age calculation.
File Description
packages/​host/​vscode-ui/​src/​pickers.tsx Aliases shortRevisionLabel to the shared name helper.
packages/​host/​inspector/​src/​app/​revisions.ts Uses shared formatting and retains age as an alias.
packages/​host/​core/​test/​revision-label.test.mjs Tests label round trips, parsing, and revision ages.
packages/​host/​core/​src/​ui/​pickers.tsx Uses the shared helper for compact revision names.
packages/​host/​core/​src/​stage/​labels.tsx Uses the shared parser for pane labels.
packages/​host/​core/​src/​stage/​chip-text.tsx Replaces local chip parsing with the shared parser.
packages/​host/​core/​src/​revision-label.ts Defines revision-label types and shared helpers.
packages/​host/​core/​src/​pair.ts Updates label documentation to reference the shared helpers.
packages/​host/​core/​src/​index.ts Exports the revision-label helpers and type.
docs/​guides/​host-core.md Documents the revision-label format and API.

Review effort: Balanced

@agorischek
agorischek force-pushed the revision-labels branch 2 times, most recently from 00bcebb to f438e6f Compare November 21, 2026 01:08
agorischek and others added 3 commits November 21, 2026 12:34
The rule for when a running job's indicator shows (after 300 ms, then for at least 400 ms) lived in the VS Code UI,
so the default UI's "Updating…" chip showed for every job, however short. The rule is now the core's:
`runningIndicator` and its constants at `@githubnext/projections-host/running` (no React or DOM, for the VS Code
extension host), and `useRunningIndicator`, which the default UI's chip and the VS Code UI's summary bar both use. The
VS Code UI's `./running` entry re-exports it, so the extension is unchanged.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
The running indicator's minimum started while a loading pane kept the chip hidden, so a chip revealed as the renderer
became ready could vanish at once. The latch now lives only while no pane is loading.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
The Inspector wrote revision labels as `name · detail · when`, and four places read them back by splitting on ` · `
with their own rules: the default UI's and the VS Code UI's pair pickers (one trimmed, one didn't), the pane chips
(with an age heuristic) and the pane label bands. The core now owns the format: `formatRevisionLabel`,
`parseRevisionLabel`, `revisionLabelName` and `revisionAge` (the Inspector's `age`, moved). Every reader and the
Inspector's writer use them; `shortRevisionLabel` and the Inspector's `age` keep their names.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Base automatically changed from running-indicator to main November 21, 2026 21:12
@agorischek
agorischek merged commit 6654ed0 into main Nov 21, 2026
48 checks passed
@agorischek
agorischek deleted the revision-labels branch November 21, 2026 21:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants